home *** CD-ROM | disk | FTP | other *** search
/ User's Choice Windows CD / User's Choice Windows CD (CMS Software)(1993).iso / misc1 / iv26_w30.zip / INTERVIE / RUBCURVE.H < prev    next >
C/C++ Source or Header  |  1980-01-03  |  6KB  |  200 lines

  1. /*
  2.  * Copyright (c) 1987, 1988, 1989 Stanford University
  3.  *
  4.  * Permission to use, copy, modify, distribute, and sell this software and its
  5.  * documentation for any purpose is hereby granted without fee, provided
  6.  * that the above copyright notice appear in all copies and that both that
  7.  * copyright notice and this permission notice appear in supporting
  8.  * documentation, and that the name of Stanford not be used in advertising or
  9.  * publicity pertaining to distribution of the software without specific,
  10.  * written prior permission.  Stanford makes no representations about
  11.  * the suitability of this software for any purpose.  It is provided "as is"
  12.  * without express or implied warranty.
  13.  *
  14.  * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  15.  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
  16.  * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  17.  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  18.  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  19.  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
  20.  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  21.  */
  22.  
  23. /*
  24.  * Rubberbanding for curves.
  25.  */
  26.  
  27. #ifndef rubcurve_h
  28. #define rubcurve_h
  29.  
  30. #include <InterViews/rubband.h>
  31.  
  32. class RubberEllipse : public Rubberband {
  33. public:
  34.     RubberEllipse(
  35.         Painter*, Canvas*, Coord cx, Coord cy, Coord rx, Coord ry,
  36.     Coord offx = 0, Coord offy = 0
  37.     );
  38.  
  39.     virtual void GetOriginal(Coord& cx, Coord& cy, Coord& rx, Coord& ry);
  40.     virtual void GetCurrent(Coord& cx, Coord& cy, Coord& rx, Coord& ry);
  41.     virtual void OriginalRadii(int& xr, int& yr);
  42.     virtual void CurrentRadii(int& xr, int& yr);
  43.     virtual void Draw();
  44. protected:
  45.     Coord centerx, radiusx;
  46.     Coord centery, radiusy;
  47. };
  48.  
  49. class SlidingEllipse : public RubberEllipse  {
  50. public:
  51.     SlidingEllipse(
  52.         Painter*, Canvas*, Coord cx, Coord cy, Coord xr, Coord yr,
  53.     Coord rfx, Coord rfy, Coord offx = 0, Coord offy = 0
  54.     );
  55.     virtual void GetCurrent(Coord& cx, Coord& cy, Coord& xr, Coord& yr);
  56.     virtual void OriginalRadii(int&, int&);
  57.     virtual void CurrentRadii(int&, int&);
  58. protected:
  59.     Coord refx;
  60.     Coord refy;
  61. };
  62.  
  63. class RubberCircle : public RubberEllipse {
  64. public:
  65.     RubberCircle(
  66.         Painter*, Canvas*, Coord cx, Coord cy, Coord rx, Coord ry,
  67.     Coord offx = 0, Coord offy = 0
  68.     );
  69.  
  70.     virtual void OriginalRadii(int& xr, int& yr);
  71.     virtual void CurrentRadii(int& xr, int& yr);
  72.     virtual void Draw();
  73. };
  74.  
  75. class RubberPointList : public Rubberband {
  76. public:
  77.     RubberPointList(
  78.         Painter*, Canvas*, Coord px[], Coord py[], int n,
  79.     Coord offx = 0, Coord offy = 0
  80.     );
  81.     ~RubberPointList();
  82. protected:
  83.     void Copy(Coord*, Coord*, int, Coord*&, Coord*&);
  84. protected:
  85.     Coord *x;
  86.     Coord *y;
  87.     int count;
  88. };    
  89.  
  90. class RubberVertex : public RubberPointList {
  91. public:
  92.     RubberVertex(
  93.         Painter*, Canvas*, Coord px[], Coord py[], int n, int pt,
  94.     Coord offx = 0, Coord offy = 0
  95.     );
  96.  
  97.     virtual void GetOriginal(Coord*& px, Coord*& py, int& n, int& pt);
  98.     virtual void GetCurrent(Coord*& px, Coord*& py, int& n, int& pt);
  99. protected:
  100.     void DrawSplineSection (Painter*, Canvas*, Coord x[], Coord y[]);
  101. protected:
  102.     int rubberPt;
  103. };
  104.  
  105. class RubberHandles : public RubberVertex {
  106. public:
  107.     RubberHandles(
  108.         Painter*, Canvas*, Coord x[], Coord y[], int n, int pt, int size,
  109.     Coord offx = 0, Coord offy = 0
  110.     );
  111.  
  112.     virtual void Track(Coord x, Coord y);
  113.     virtual void Draw();
  114. protected:
  115.     int d;    /* half of handle size */
  116. };
  117.  
  118. class RubberSpline : public RubberVertex {
  119. public:
  120.     RubberSpline(
  121.         Painter*, Canvas*, Coord px[], Coord py[], int n, int pt,
  122.     Coord offx = 0, Coord offy = 0
  123.     );
  124.  
  125.     virtual void Draw();
  126. };
  127.  
  128. class RubberClosedSpline : public RubberVertex {
  129. public:
  130.     RubberClosedSpline(
  131.         Painter*, Canvas*, Coord px[], Coord py[], int n, int pt,
  132.     Coord offx = 0, Coord offy = 0
  133.     );
  134.  
  135.     virtual void Draw();
  136. };
  137.  
  138. class SlidingPointList : public RubberPointList {
  139. public:
  140.     SlidingPointList (
  141.         Painter*, Canvas*, Coord px[], Coord py[], int n,
  142.     Coord rfx, Coord rfy, Coord offx = 0, Coord offy = 0
  143.     );
  144.  
  145.     virtual void GetOriginal(Coord*& px, Coord*& py, int& n);
  146.     virtual void GetCurrent(Coord*& px, Coord*& py, int& n);
  147.     virtual void Draw();
  148.     virtual void Track(Coord x, Coord y);
  149. protected:
  150.     Coord refx;
  151.     Coord refy;
  152. };
  153.  
  154. class SlidingLineList : public SlidingPointList {
  155. public:
  156.     SlidingLineList(
  157.         Painter*, Canvas*, Coord x[], Coord y[], int n,
  158.     Coord rfx, Coord rfy, Coord offx = 0, Coord offy = 0
  159.     );
  160.  
  161.     virtual void Draw();
  162. };    
  163.  
  164. class ScalingLineList : public RubberPointList {
  165. public:
  166.     ScalingLineList (
  167.         Painter*, Canvas*, Coord px[], Coord py[], int n,
  168.         Coord cx, Coord cy, Coord rfx, Coord rfy,
  169.     Coord offx = 0, Coord offy = 0
  170.     );
  171.     virtual ~ScalingLineList();
  172.  
  173.     virtual void GetOriginal(Coord*& px, Coord*& py, int& n);
  174.     virtual void GetCurrent(Coord*& px, Coord*& py, int& n);
  175.     virtual void Track(Coord, Coord);
  176.     virtual void Draw();
  177.     float CurrentScaling();
  178. protected:
  179.     virtual void Update();
  180. protected:
  181.     Coord* newx, *newy;
  182.     Coord centerx, centery;
  183.     float origVal;
  184. };
  185.  
  186. class RotatingLineList : public ScalingLineList {
  187. public:
  188.     RotatingLineList (
  189.         Painter*, Canvas*, Coord px[], Coord py[], int n,
  190.         Coord cx, Coord cy, Coord rfx, Coord rfy,
  191.     Coord offx = 0, Coord offy = 0
  192.     );
  193.     float OriginalAngle() { return origVal; }
  194.     float CurrentAngle();
  195. protected:
  196.     virtual void Update();
  197. };
  198.  
  199. #endif
  200.